package main

import (
	"fmt"

	"file_explorer/resource"
	"file_explorer/view/components"
	"file_explorer/view/packed_widgets"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func testWindow() {
	app := app.New()
	window := app.NewWindow("")

	rows, cols := 10, 10

	table := widget.NewTable(func() (int, int) {
		return rows, cols
	}, func() fyne.CanvasObject {
		return container.NewHBox(
			widget.NewIcon(nil),
			packed_widgets.NewLabel(""),
		)
	}, func(id widget.TableCellID, cell fyne.CanvasObject) {
		ct := cell.(*fyne.Container)
		label := ct.Objects[1].(*packed_widgets.Label)
		//label.SetText(strconv.Itoa(id.Row) + "," + strconv.Itoa(id.Col))
		label.Resize(ct.Size())
		label.OnTapped = func() {
			fmt.Println("tapped", id.Row, id.Col)
		}
	})

	for i := 0; i < rows; i++ {
		table.SetColumnWidth(i, 100)
	}

	window.SetContent(table)

	window.Resize(fyne.NewSize(600, 800))
	app.Settings().SetTheme(&resource.FeTheme{})
	window.ShowAndRun()
}

func main() {
	//testWindow()
	//return
	mainWindow := components.NewMainWindow()
	mainWindow.App.Settings().SetTheme(&resource.FeTheme{})
	mainWindow.ShowAndRun()
}
